home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
Apple Script
/
OSAX
/
Four Password OSAXen
/
PassWord4 Folder
/
PassWord4.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-05-14
|
2KB
|
61 lines
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Password4.c
// Written by: Donald Olson
// May 1993
// Copyright ® 1993 Apple Computer Inc.
// All rights reserved.
//
// This is a simple Scripting Addition that clears a password that
// has been stored in the User PassWord3 or User PassWord2 scripting
// addition. This was written for a talk at the 1993 WWDC given
// by Donald Olson and Donn Denman.
//
// Syntax: Clear Password
// Return: None.
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <string.h>
#include <Dialogs.h>
#include <AppleEvents.h>
#include <Memory.h>
// Our constants
#define MYClass 'OLIE'
#define MyID 'psw3'
#define MyID2 'psw2'
pascal OSErr main(AppleEvent *theEvent,
AppleEvent *theReply,
long theRefCon) {
OSErr theErr = noErr;
EventHandlerProcPtr handler;
long handlerRefcon = 0;
DescType theID = MyID;
theErr = AEGetEventHandler(MYClass, theID,
&handler, &handlerRefcon, true);
if(theErr != noErr) {
/*
Maybe it was installed with the first of our osaxes,
try again with its ID
*/
theID = MyID2;
theErr = AEGetEventHandler(MYClass, theID,
&handler, &handlerRefcon, true);
if(theErr != noErr) return theErr;
}
if(handlerRefcon != 0)
DisposeHandle((Handle)handlerRefcon); // Get rid of our handle
theErr = AEInstallEventHandler(MYClass, theID,
handler, 0, true);
return theErr;
}